/**
 * 
 */
package slhs.tempo.scriptGenerator;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * FeedbackOptionsPopup.java
 * 
 * @author Swapnil Devikar
 * 
 */
public class FeedbackOptionsPopup extends JFrame {

    private static final String RESPONSE_BOX_FEEDBACK_STRING = "0;True;True;0;False";
    private static FeedbackOptionsPopup feedbackOptionsPopup = new FeedbackOptionsPopup();
    private static JPanel basePanel;
    private static String type = "";

    private FeedbackOptionsPopup() {
	super("Feedback Options");
	this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	basePanel = new JPanel();
	this.add(basePanel);
	setSize(550, 450);

    }

    public static FeedbackOptionsPopup getInstance(String feedbackType) {
	type = feedbackType;
	basePanel.removeAll();
	JPanel feedbackPanel = FeedbackOptionsPanelFactory.getInstance().getPanel(feedbackType);
	feedbackPanel.revalidate();
	basePanel.add(feedbackPanel);
	basePanel.revalidate();
	basePanel.repaint();
	return feedbackOptionsPopup;
    }

    /**
     * Helper method to show/hide the popup
     */
    void draw(boolean show, Dimension dim) {
	this.repaint();
	this.setVisible(show);
	this.setSize(dim);
    }

    /**
     * @return
     */
    public static String getFeedbackOptions() {
	String feedbackString = "";
	if (type.equals(UtilityConstants.WORD_FEEDBACK)) {
	    feedbackString = WordFeedbackPanel.getInstance().getFeedbackString();
	} else if (type.equals(UtilityConstants.IMAGE_FEEDBACK)) {
	    feedbackString = ImageFeedbackPanel.getInstance().getFeedbackString();
	} else if (type.equals(UtilityConstants.AUDIO_FEEDBACK)) {
	    feedbackString = AudioFeedbackPanel.getInstance().getFeedbackString();
	} else {
	    feedbackString = RESPONSE_BOX_FEEDBACK_STRING;
	}
	return feedbackString;
    }

}
